<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
    <script>  
    //获取绝对值
    console.log(Math.abs(121));    //获取绝对值，正数直接为正数,故输出121
    console.log(Math.abs(-121));   //获取绝对值，负数转换为正数,故输出121
    console.log(Math.abs('121'));  //获取绝对值，自动转换为数字,故输出121
    console.log(Math.abs('b'));    //获取绝对值，无法转换为数字,故输出NaN
    //次幂
    console.log(Math.pow(2,3));    //获取2的3次幂，故输出8
    console.log(Math.pow(2,-3));   //获取2的-3次幂，故输出0.125
    console.log(Math.pow(1.1,2));  //获取1.1的2次幂，故输出1.21
    //平方根
    console.log(Math.sqrt(4));     //获取正整数4的平方根，故输出2
    console.log(Math.sqrt(1.21));  //获取浮点数1.21的平方根，故输出1.1
    console.log(Math.sqrt(-4));    //获取负数-4的平方根，负数无平方根，故输出NaN
    //向上取整
    console.log(Math.ceil(1.2));
    console.log(Math.ceil(1.5));
    console.log(Math.ceil(1.8));
    console.log(Math.ceil(-1.2));
    console.log(Math.ceil(-1.5));
    console.log(Math.ceil(-1.8));
   //向下取整
    console.log(Math.floor(1.2));
    console.log(Math.floor(1.5));
    console.log(Math.floor(1.8));
    console.log(Math.floor(-1.2));
    console.log(Math.floor(-1.5));
    console.log(Math.floor(-1.8));

    //四舍五入
    console.log(Math.round(1.2));
    console.log(Math.round(1.5));
    console.log(Math.round(1.8));
    console.log(Math.round(-1.2));
    console.log(Math.round(-1.5));
    console.log(Math.round(-1.8));

    //向上取整
    console.log(Math.ceil(1.2));
    console.log(Math.ceil(-1.8));
    //向下取整
    console.log(Math.floor(1.8));
    console.log(Math.floor(-1.2));
</script>

</head>
<body>
    
</body>
</html>